package com.lemner.motion.activity;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lemner.motion.R;
import com.lemner.motion.base.BaseActivity;
import com.lemner.motion.util.FullScreen;
import com.lemner.motion.util.SharedPreferencesUtils;

public class UserSettingActivity extends BaseActivity{
        private ImageView iv_back;
        private LinearLayout ll_pwd,ll_logout;
        private String id;
        private AlertDialog dialog;
    @Override
    public int getLayoutFile() {
        return R.layout.activity_user_setting;
    }

    @Override
    public void initView() {
        FullScreen.fullScreen(this,0x0020c26f);
        iv_back=(ImageView)findViewById(R.id.iv_back);
        ll_pwd=(LinearLayout) findViewById(R.id.ll_pwd);
        ll_logout=(LinearLayout)findViewById(R.id.ll_logout);
        initLogout();
    }

    public void initLogout(){
        dialog= new AlertDialog.Builder(UserSettingActivity.this).setTitle("系统提示").setMessage("是否确认注销？")
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        SharedPreferencesUtils utils=new SharedPreferencesUtils(UserSettingActivity.this);
                        utils.clearSp();
                        Intent intent2=new Intent(UserSettingActivity.this,IndexActivity.class);
                        startActivity(intent2);
                        finish();
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                }).create();
    }

    @Override
    public void initEvent() {
        iv_back.setOnClickListener(this);
        ll_pwd.setOnClickListener(this);
        ll_logout.setOnClickListener(this);
    }

    @Override
    public void initData() {
     id=getIntent().getStringExtra("studentid");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_back:
                Intent intent=new Intent(UserSettingActivity.this,StartRunActivity.class);
                intent.putExtra("flag",true);
                startActivity(intent);
                finish();
                break;
            case R.id.ll_pwd:
                Intent intent1=new Intent(UserSettingActivity.this,ChangePwdActivity.class);
                intent1.putExtra("studentid",id);
                startActivity(intent1);
                finish();
                break;
            case R.id.ll_logout:
                dialog.show();
                break;

        }
    }

}
